<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    {include file="/layout/scriptload"}
    <title>系统管理</title>
</head>
<body>
<div class="box">
    <!-- /.box-header -->
    <section class="content">
        <div class="box-body">
            <form role="form">
                <div class="form-group col-md-7" >
                    <label>公众号昵称</label>
                    <input type="text" id="name" class="form-control" value="{$data.wechatname}" placeholder="昵称...">
                </div>
                <input type="hidden" id="aid" value="{$data.id}">
                <div class="form-group col-md-7" >
                    <label>原始ID<span style="color: #f71752;">（ghid）</span></label>
                    <input type="text" id="ghid" class="form-control" value="{$data.ghid}" placeholder="原始ID...">
                </div>
                <div class="form-group col-md-7" >
                    <label>appId</label>
                    <input type="text" id="appid" class="form-control" value="{$data.appid}" placeholder="appId...">
                </div>
                <div class="form-group col-md-7" >
                    <label>appSecret</label>
                    <input type="text" id="appsecret" class="form-control" value="{$data.appsecret}" placeholder="appSecret...">
                </div>
                <div class="form-group col-md-7">
                    <div id="btn_save" class="btn btn-info btn-flat pull-right">保存</div>
                </div>
            </form>
        </div>
    <!-- /.box-body -->
    </section>
</div>
</body>
<script>
    $(function(){
        $('#btn_save').click(function(){
            var _title = $('#name').val();
            var _pid = $('#ghid').val();
            var _modulea = $('#appid').val();
            var _route = $('#appsecret').val();
            var _id = $('#aid').val();
            if(_title == ""){
                layerAlert('请输入公众号昵称');
                return false;
            }
            if(_pid == ""){
                layerAlert('请输入ghid');
                return false;
            }
            if(_modulea == ''){
                layerAlert('请输入appid');
                return false;
            }
            if(_route == ''){
                layerAlert('请输入appsecret');
                return false;
            }
            $.ajax({
                cache: false,
                url:"{:url('template/doEditAccount')}",
                data:{name:_title,ghid:_pid,appid:_modulea,appsecret:_route,aid:_id},
                type:'post',
                success:function(data){
                    if(data.code==0){
                        layerAlert('修改成功',function(){
                            layerParentClose();
                            parent.window.location.reload();
                        })
                    }else{
                        layerAlert('修改失败');
                    }
                },
                error:function () {
                    layerAlert('系统错误，请联系管理员');
                }
            })
        })
    })
</script>
</html>